﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using DataAccess_Layer;
using Business_Layer;
using System.Collections;
public partial class MyAdmin_TaoTKHeAdmin : System.Web.UI.Page
{
    LogAction log = new LogAction();
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {

        DropDownList cbbRole = (DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("cbbRole");
        TextBox userNameTextBox = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("UserName");

        MembershipUser user = Membership.GetUser(userNameTextBox.Text);
        Roles.AddUsersToRole(new string[] { user.UserName }, cbbRole.SelectedItem.ToString());
        //log
        log.TenLoaiCapNhat = "Thêm";
        log.Ngay = DateTime.Now;
        log.TenBang = "Bảng Tài khoản admin";
        log.TenLoaiDangNhap = "Admin";
        log.TenDangNhap = Helper.getCurrentAdminUserName(Session);
   
        log.DuLieuCu = "X";
  
        log.DuLieuMoi = "Username: " + userNameTextBox.Text
            + "..\nRole: cbbRole.SelectedItem.ToString()";
        Log_BUS.insert(log);
        //log
    }
    protected void ContinueButton_Click(object sender, EventArgs e)
    {
        Response.Redirect(Helper.getCurrentPageName(Request.Url));
    }
    protected void RoleLinqDataSource_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    {
        DropDownList cbbRole = (DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("cbbRole");
        e.Result = DataAccess_Layer.RoleDAC.layHetTruAdmin();
    }
}